<?php
namespace app\common\model;

class PlatformBalanceLog extends Base
{
    protected $table = 'platform_balance_logs';

    protected static function init()
    {

    }

    public function getCreateTimeLabelAttr($value, $data)
    {
        if (empty($data['create_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['create_time']);
    }

    public function getStatusTimeLabelAttr($value, $data)
    {
        if (empty($data['status_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['status_time']);
    }

    public function getPlatformIdLabelAttr($value, $data)
    {
        $platform = Platform::get(array('id' => $data['platform_id']));
        if (empty($platform)) {
            return '未知';
        }

        return $platform['name'];
    }

    public function getStatusArrAttr($value, $data)
    {
        switch ($data['status']) {
            case 1:
                $result['status_label'] = '已获取';
                $result['status_class'] = 'layui-btn-default';
                break;
            case -1:
                $result['status_label'] = '已退回';
                $result['status_class'] = 'layui-btn-danger';
                break;
            default:
                $result['status_label'] = '未获取';
                $result['status_class'] = 'layui-btn-primary';
                break;
        }

        return $result;
    }

    public function getMoneyArrAttr($value, $data)
    {
        if ($data['money_type'] == 1) {
            return array('money_class' => '', 'money_label' => '-' . $data['money']);
        }

        if ($data['money_type'] == 2) {
            return array('money_class' => 'red', 'money_label' => '+' . $data['money']);
        }

        return array('money_class' => '', 'money_label' => '');
    }

}